"""
应用GBTD算法对乳腺癌数据集进行训练和预测。
要求：使用的决策树为30颗，输出训练集和测试集的得分。（分值：15；结果：截图呈现图片命令为图5，代码命名4.py）
"""
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
from sklearn.ensemble import GradientBoostingClassifier as GBTD

cancer = load_breast_cancer()
x_train, x_test, y_train, y_test = train_test_split(cancer.data, cancer.target)
gbtd = GBTD(n_estimators=30)
gbtd.fit(x_train, y_train)
train_score = gbtd.score(x_train, y_train)
test_score = gbtd.score(x_test, y_test)
print(f"训练得分:{train_score:.2f}")
print(f"测试得分:{test_score:.2f}")
